// MainWindow.cs created with MonoDevelop
// User: jmartin at 08:24 03/10/2007
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//
using System;
using Gtk;
using System.Threading;


public partial class MainWindow: Gtk.Window
{	
	bool trans=false;

	
	public MainWindow (): base (Gtk.WindowType.Toplevel)
	{
		
		Build ();
		this.Hide();
		//ajustos de la finestra
		this.KeepAbove=true;
		this.trans=false;
		
		//ajustos del label

		
	}
	

	public void  drawTrans( ){
		
		int w;
		int h;
		int left;
		int top;
		this.GetSize(out w,out h);
		this.GetPosition(out left,out top);
		Gdk.Pixbuf bg = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, w, h);
		//Gdk.Pixbuf bg = new Gdk.Pixbuf("trans.png");
		this.Hide();
		while (Gtk.Application.EventsPending ())
			Gtk.Application.RunIteration ();
		bg.GetFromDrawable(Gdk.Screen.Default.RootWindow, Gdk.Screen.Default.RootWindow.Colormap ,left, top ,0,0, w, h);
		//bg.AddAlpha(true,0,0,0);
		while (Gtk.Application.EventsPending ())
			Gtk.Application.RunIteration ();
		Gdk.Pixmap pfons; 
		Gdk.Pixmap pmask;
		bg.RenderPixmapAndMask(out pfons,out pmask,255);
		this.Style.SetBgPixmap(StateType.Normal,pfons);
		this.Decorated=false;
		this.trans=true;
		this.Show();
		this.Move(left,top);
	}
	
	
	public void setInfoWidth(int width){
		this.infoLabel.WidthRequest=width;
		if (trans==true)
			drawTrans();
		
	}
	
	
   public  int  getInfoHeight(){
		int h=0;
		int w=0;
		infoLabel.Layout.GetPixelSize(out w,out h);
		return h;
	}
	
	
	public void setPixbuf(string image){
		
		infoImage.Pixbuf= new Gdk.Pixbuf(image);
	}


	
	public void write(string text){
		infoLabel.Markup=text;
		

	}

	public void windowBgColor(Gdk.Color col){
		this.ModifyBg(StateType.Normal,col);
		this.ModifyBg(StateType.Insensitive,col);
		this.ModifyBg(StateType.Active,col);
		this.ModifyBg(StateType.Selected,col);
		this.ModifyBg(StateType.Prelight,col);
	}
	
	
	public void infoBgColor(Gdk.Color col){

		/*
		Gdk.Pixbuf bg = new Gdk.Pixbuf("/home/jmartin/gtkagent/gtkagent/Hat_128x128.png");
		Gdk.Pixmap pfons; 
		Gdk.Pixmap pmask;
		bg.RenderPixmapAndMask(out pfons,out pmask,0);
		ebox.Style.SetBgPixmap(StateType.Active,pfons);
		*/

		//Gdk.Color col = new Gdk.Color();
		//Gdk.Color.Parse(color, ref col);
		ebox.ModifyBg(StateType.Normal,col);
		ebox.ModifyBg(StateType.Insensitive,col);
		ebox.ModifyBg(StateType.Active,col);
		ebox.ModifyBg(StateType.Selected,col);
		ebox.ModifyBg(StateType.Prelight,col);

	}

	public void infoFontFamily(string font){
		infoLabel.PangoContext.FontDescription.Family=font;
		
		
	}

	public void infoFontStyle(Pango.Style style){
		infoLabel.PangoContext.FontDescription.Style=style;
		
	}	
	
	public void infoFontSize(int size){
		infoLabel.PangoContext.FontDescription.AbsoluteSize=size;
		
	}
	

	
	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}


}